<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="description" content="" />
    <meta name="author" content="ChongMing" />
    <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-touch-fullscreen" content="yes">
    <meta name="full-screen" content="yes">
    <meta name="screen-orientation" content="portrait">
    <meta name="x5-fullscreen" content="true">
    <meta name="360-fullscreen" content="true">
    <title>订单详情</title>
</head>
<link rel="stylesheet" href="../css/reset.css">
<link rel="stylesheet" href="../css/swiper-3.3.1.min.css">
<link rel="stylesheet" href="css/geneticTesting.css">
<script type="text/javascript" src="../js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="../js/jquery.mobile-1.4.3.js"></script>
<script type="text/javascript" src="../js/swiper-3.3.1.jquery.min.js"></script>
<script type="text/javascript" src="js/geneticTesting.js"></script>
<script type="text/javascript" src="js/vue.js"></script>
<script type="text/javascript" src="js/jquery.cookie.js"></script>
<script src="js/ap.js"></script>
<script src="js/pingpp.js"></script>
<script src="../js/rem.js"></script>
<script type="text/javascript">
    $(function(){
//        $('body').on('touchmove', function (event) {
//            event.preventDefault();
//        });

        if($.cookie("is_wechat")==1){
            $('.sub-order .order-detail .mode .right .wechat').hide();
            $('.sub-order .order-detail .mode .right .alipay .radio').hide();
            pay_type = 'alipay_wap';
        }else{
            pay_type = 'wx_pub';
        }
        $('.sub-order .order-detail .mode .right .wechat').click(function(){
            pay_type = 'wx_pub';
        });
        $('.sub-order .order-detail .mode .right .alipay').click(function(){
            pay_type = 'alipay_wap';
        });
        var address_id = geneticTesting.getQueryString('address_id');

        var data = {
            uid:$.cookie("local_userId"),
            product_str: '['+$.cookie('product_str')+']',
            is_preview:1,
            address_id:address_id
        }
        geneticTesting.ord_preview2('shop/order',data)

        if($.cookie('num')){
            num = $.cookie('num');

            $('.sub-order .botpay .left .text .span_1').html('￥'+$.cookie('price')*num);
            $('.sub-order .botpay .left .text .span_2').html('(已省：￥'+num*$.cookie('sp')+')')
        }else{
            num = 1;
        }
        $('.sub-order .order-detail .buy-num .right .num').html(num);
        $('.sub-order .order-detail .buy-num .right .plus').click(function(){
            var price = $('#sub-order').data('price');
            var sp = $('body').attr('data-sp');
            num++
            $('.sub-order .order-detail .buy-num .right .num').html(num);
            $('.sub-order .botpay .left .text .span_1').html('￥'+price*num);
            $('.sub-order .botpay .left .text .span_2').html('(已省：￥'+num*sp+')')
        });
        $('.sub-order .order-detail .buy-num .right .reduce').click(function(){
            var price = $('#sub-order').data('price');
            var sp = $('body').attr('data-sp');
            if(num>1){
                num--
                $('.sub-order .order-detail .buy-num .right .num').html(num);
                $('.sub-order .botpay .left .text .span_1').html('￥'+price*num);
                $('.sub-order .botpay .left .text .span_2').html('(已省：￥'+num*sp+')')
            }else{
                num = 1
                $('.sub-order .order-detail .buy-num .right .num').html(num);
            }
        });
        code = geneticTesting.getQueryString("code");
        if(code){
            $.ajax({
                type: 'GET',
                url:  url + '/diagnosis/getcharge/',
                data: {         // 需要于客户端同步
                    uid: $.cookie("local_userId"),
                    order_id: geneticTesting.getQueryString("order_id"),
                    pay_method:"wx_pub",
                    code : code
                },
                dataType: 'jsonp',
                jsonp: 'callback',
                success: function (result) {
                    pingpp.createPayment(result.data.charge, function(result, err) {
                        if (result=="success") {
                            location.href = '../shoppingMall/shopdetail.html?order_id='+geneticTesting.getQueryString("order_id");
                        } else {
                            console.log(result.data.msg);
                        }
                    });
                }
            });
        }

        //    点击支付
        $('.sub-order .botpay .right').click(function(){
            var address_id = $(this).data('address_id');
            var num = $('.sub-order .order-detail .buy-num .right .num').html();
            var price = $('#sub-order').data('price');
            var sp = $('body').attr('data-sp');
            var memo = $('.sub-order .order-detail .remarks input').val();
            $.cookie('num',num,{expirse:7,path:'/'});
            $.cookie('price',price,{expirse:7,path:'/'});
            $.cookie('sp',sp,{expirse:7,path:'/'});

            var data = {
                uid:$.cookie("local_userId"),
                product_str:'['+encodeURI($.cookie('product_str'))+']',
                memo:memo,
                address_id:address_id
            }
            geneticTesting.get('shop/order',data,function(res){
                if(res.ret==0){
                    console.log(res);
                    var data = res.data;
                    var odid = data.order_id
                    $.ajax({
                        type: 'GET',
                        url:  url + '/diagnosis/getcharge/',
                        data: {         // 需要于客户端同步
                            uid: $.cookie("local_userId"),
                            order_id: data.order_id,
                            pay_method:pay_type,
                            success_url : 'http://www.ekangjiuyi.net/EKang2.0/hospital_nurse/submitorder-shop.html'
                        },
                        dataType: 'jsonp',
                        jsonp: 'callback',
                        success: function (result) {
                            if(pay_type == "alipay_wap"){
                                pingpp.createPayment(result.data.charge, function(result, err) {
                                    if (result=="success") {
                                        location.href = '../shoppingMall/shopdetail.html?order_id='+odid;
                                    }
                                });
                            }else{
                                var url = result.data.location_url;
                                location.href = url;
                            }
                        }
                    });
                }
                else{
                    alert(res.msg);
                }
            });
        });
//        $('.sub-order .address-infor').click(function(){
//            location.href = '../editAdd.html'
//        });
    });
</script>
<style>
    .sub-order .order-detail .coupon {
        width: auto;
        height: auto;
        overflow: hidden;
        margin: 0 10px;
        padding: 15px 0;
        border-bottom: 1px solid #eee;
    }
    .sub-order .order-detail .coupon .left{
        font-size: 4.3vw;
        color: #666;
        float: left;
        line-height: 5.6vw;
        line-height: 7.8vw;
    }
    .sub-order .order-detail .coupon img{
        float:right;
        width: 8%;
    }
</style>
<body style=" background: #ebebeb; margin: auto;-webkit-overflow-scrolling: touch;overflow: scroll;">
<div class="sub-order" id="sub-order-shop" data-price="{{total_amount}}">
    <div v-on:click="link2(address_id)" v-if="is_have_address==0" class="add-address">
        <img src="images/icon29.png">
        <p>还没收货地址<span>去添加</span></p>
    </div>
    <div v-on:click="link(address_id)" v-if="is_have_address==1" class="address-infor">
        <div class="name public"><p>收货人：</p><span>{{user_name}}</span></div>
        <div class="add public"><p>收货地址：</p><span>{{address_desc}}</span></div>
        <div class="phone public"><p>联系方式：</p><span>{{mobile}}</span></div>
    </div>
    <div class="order-detail" style=" margin-bottom: 16.6vw;">
        <div class="price" v-for="list in product_list">
            <div class="left">
                <img style=" width: 1.54rem; height: 1.4rem;" v-bind:src="list.goods_thumb">
                <!--<p>{{gene_name}}</p>-->
            </div>
            <div class="right" style=" width:70%;float:left; margin:0 0px 0px 10px;">
                <p style=" font-size: 0.25rem; margin-bottom: 10px; line-height: 0.4rem; width: 100%; color: #555;" class="name">{{list.product_name}}</p>

                <p style="font-size: 0.35rem;">￥{{list.unit_price}}<span style=" font-size: 0.28rem; color: #999;">x{{list.num}}</span></p>

            </div>
        </div>
        <!--<div class="buy-num">-->
            <!--<p class="left">购买数量</p>-->
            <!--<div class="right">-->
                <!--<div class="plus public">+</div>-->
                <!--<div class="num"></div>-->
                <!--<div style=" line-height: 4.6vw" class="reduce public">-</div>-->
            <!--</div>-->
        <!--</div>-->
        <!--<div class="coupon">-->
            <!--<p class="left">优惠券</p>-->
            <!--<img src="../img/icon_right.png">-->
        <!--</div>-->
        <div class="mode">
            <p class="left">支付方式</p>
            <div class="right">
                <div class="wechat public">
                    <img class="icon" src="../hospital_nurse/images/icon42.png">
                    <img class="radio" src="../hospital_nurse/images/icon41.png">
                </div>
                <div class="alipay public">
                    <img class="icon" src="../hospital_nurse/images/icon43.png">
                    <img class="radio" src="../hospital_nurse/images/icon40.png">
                </div>
            </div>
        </div>
        <div class="remarks">
            <p class="left">备注：</p>
            <input type="text">
        </div>
    </div>
    <div class="botpay">
        <div class="left">
            <div class="text"><span class="span">合计：</span><span class="span_1"></span></div>
        </div>
        <div class="right" data-address_id="{{address_id}}">支付</div>
    </div>
</div>
</body>
</html>